import machine, os

try:
    SystemLogger().log('mountsd: Mounting SD Card')
    sd = machine.SDCard(slot=2)

    os.mount(sd, '/sd')
    statvfs = os.statvfs('/sd')
    SystemLogger().log('SD Card mounted at /sd')
    SystemLogger().log("SD File system block size: {}".format(statvfs[0]))
    SystemLogger().log("SD Fragment size: {}".format(statvfs[1]))
    SystemLogger().log("SD Size of file system in fragment size units: {}".format(statvfs[2]))
    SystemLogger().log("SD Number of free blocks: {}".format(statvfs[3]))
    SystemLogger().log("SD Number of free blocks for unprivileged users: {}".format(statvfs[4]))
    SystemLogger().log("SD Number of inodes: {}".format(statvfs[4]))
    SystemLogger().log("SD Number of free inodes: {}".format(statvfs[5]))
    SystemLogger().log("SD Number of free inodes for unprivileged users: {}".format(statvfs[6]))
    SystemLogger().log("SD Mount flags: {}".format(statvfs[7]))
    SystemLogger().log("SD Maximum filename length: {}".format(statvfs[9]))
except Exception as e:
    SystemLogger().log(f"Failed to mount SD card: {e}")
